# -*- coding: utf-8 -*-
from datetime import datetime
from django.db import models

from apps.courses.models import Course
from apps.users.models import UserProfile


class UserAsk(models.Model):
    """
    用户咨询课程信息
    """
    name = models.CharField(verbose_name=u"用户名称",max_length=15)
    mobile = models.CharField(verbose_name=u"手机号码",max_length=11)
    courseName = models.CharField(verbose_name=u"课程名称",max_length=20)
    addTime = models.DateTimeField(verbose_name=u"咨询时间",default=datetime.now)

    class Meta:
        verbose_name = u"课程咨询"
        verbose_name_plural = verbose_name

    def __str__(self):
        return self.name


class CourseComments(models.Model):
    """
    课程评论课程信息
    """
    user = models.ForeignKey(UserProfile,verbose_name=u"用户")
    course = models.ForeignKey(Course,verbose_name=u"课程")
    comments =models.CharField(verbose_name=u"评论内容",max_length=200)
    addTime = models.DateTimeField(verbose_name=u"评论时间", default=datetime.now)

    class Meta:
        verbose_name = u"课程评论"
        verbose_name_plural = verbose_name

class UserFavorite(models.Model):
    """
    用户收藏(机构,教师,课程)信息
    """
    user = models.ForeignKey(UserProfile,verbose_name=u"用户")
    favId = models.IntegerField(verbose_name=u"收藏数据的编号",default=0)
    favType = models.IntegerField(verbose_name=u"收藏类型",choices=((1,"机构"),(2,"教师"),(3,"课程")),default=1)
    addTime = models.DateTimeField(verbose_name=u"收藏时间", default=datetime.now)

    class Meta:
        verbose_name = u"收藏信息"
        verbose_name_plural = verbose_name

class UserMessage(models.Model):
    """
    系统消息信息
    """
    # 为0:全部用户的消息,为用户的编号:指定用户的
    user = models.IntegerField(verbose_name=u"接受用户",default=0)
    message = models.CharField(verbose_name=u"消息内容",max_length=500)
    hasRead = models.BooleanField(verbose_name=u"是否已读",default=False)
    addTime = models.DateTimeField(verbose_name=u"发送时间",default=datetime.now)

    class Meta:
        verbose_name = u"消息"
        verbose_name_plural = verbose_name

class UserCourse(models.Model):
    """
    用户选课信息
    """
    user = models.ForeignKey(UserProfile,verbose_name=u"用户")
    course = models.ForeignKey(Course,verbose_name=u"课程")
    addTime = models.DateTimeField(verbose_name=u"学习时间",default=datetime.now)

    class Meta:
        verbose_name = u"选课信息"
        verbose_name_plural = verbose_name